<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    div{
        width: 100px;
        height: 100px;
        background-color: red;
        color: white;
        margin: 10px;
    }
    div:nth-child(2){
        background-color: blue;
        position: sticky;
        top: 50px;
    }
</style>
</head>
<body>
    <div>div1</div>
    <div>div2</div>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div>div3</div> 
</body>
</html>